class Solution {
public:
    int strStr(string haystack, string needle) {
        int answerindex = -1;
        if (needle.length() > haystack.length()) { return answerindex; }
        for (int i = 0; i <= haystack.length() - needle.length(); i++) {
            int index = 0;
            int j = i;
            if (haystack[j] == needle[index]) {
                while (haystack[j] == needle[index]) {
                    if (index == needle.length() - 1 && haystack[j] == needle[index]) {
                        answerindex = i;
                        return answerindex;
                    }
                    index++;
                    j++;
                }
            }
        }
        return answerindex;
    }
};
